﻿@model IEnumerable<OnlineShoppingStore.Domain.Entities.Product>

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}

<div class="panel panel-default">
    <div class="panel-heading">
        <div>All Products</div>
    </div>
    <div class="panel-body">
        <table class="table table-striped table-condensed table-bordered">
            <tr>
                <th class="text-right">ID</th>
                <th>Name</th>
                <th class="text-right">Price</th>
                <th class="text-center">Actions</th>
            </tr>
            @foreach (var item in Model)
            {
                <tr>
                    <td class="text-right">@item.ProductId</td>
                    <td>
                        @Html.ActionLink(item.Name, "Edit", new { item.ProductId })
                    </td>
                    <td class="text-right">@item.Price.ToString("c")</td>
                    <td class="text-center">
                        @using (Html.BeginForm("Delete", "Admin"))
                        {
                            @Html.Hidden("ProductId", item.ProductId)
                            <input type="submit"
                                   class="btn btn-default btn-xs"
                                   value="Delete" />
                        }
                    </td>
                </tr>
            }
        </table>
    </div>
    <div class="panel-footer">
        @Html.ActionLink("Add a New Product", "Create", null, 
        new{ @class="btn btn-default"})
    </div>
</div>